package top.scsoul.pas.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import top.scsoul.pas.entity.Student;

import java.util.List;

@Repository
public interface StudentReposotory extends JpaRepository<Student, Long> {
    @Query(value = "select count(student.student_id) from student where student_card = ?1", nativeQuery = true)
    long getCountByCard(String card);

    @Query(value = "select * from student where clazz_id = ?1", nativeQuery = true)
    List<Student> getStudentsByClazzId(Long clazzId);


    @Modifying
    @Query(value = "delete from student where student.clazz_id=?1", nativeQuery = true)
    void deleteByClazzId(Long clazzId);
}
